/////////////////////////////////////////////////////////////////////////////
/*/	
 *	Creator:		Joshua C. Rouzer
 *	Title:			Emitter Header
 *	Last Edited:	07/08/2013
 *	Summary:		
/*/
/////////////////////////////////////////////////////////////////////////////
#ifndef CEMITTER_H
#define CEMITTER_H
#include "Particle.h"
#include <vector>
using namespace std;
enum Shape {ESQUARE, ECIRCLE, EVLINE, EHLINE, EPOINT, };
class CParticleManager;
class CEmitter{
private:
	//Emitter Info
	vector<CParticle*> m_Particles;
	unsigned int m_unParticleCount;
	unsigned int m_unMaxPart;
	Shape m_eShape;
	float m_fPosX;
	float m_fPosY;
	float m_fPosX2;	//For Square/line
	float m_fPosY2; //For Square/line
	float m_fRange; //For Circle
	float m_fSpawnDelay;
	float m_fTimer;		//The countdown to next spawn
	bool m_bSpawn;
	bool m_bLooping;
	bool m_bInvert;		//If the emitter is coming inward instead of outward
	//Particle Info.
	int m_nImage;
	int m_nPartWidth;
	int m_nPartHeight;
	float m_fStScale;
	float m_fEndScale;
	float m_fSVelX;
	float m_fSVelY;
	float m_fEndVelX;
	float m_fEndVelY;
	float m_fStRot;
	float m_fEndRot;
	float m_fLifeMin;
	float m_fLifeMax;
	//Color Info.
	int m_nStAlpha;
	int m_nStRed;
	int m_nStGreen;
	int m_nStBlue;
	int m_nEndAlpha;
	int m_nEndRed;
	int m_nEndGreen;
	int m_nEndBlue;
public:
	CEmitter(int _image, int _partWidth, int _partHeight, Shape _shape, float posX, float posY,
		float posX2, float posY2, float delay, float _StScale, float _EndScale, float StVelX, float StVelY,
		float EndVelX, float EndVelY, float StRot, float EndRot, float _lifeMin, float _lifeMax,
		int _StA, int _StR, int _StG, int _StB, int _EndA, int _EndR, int _EndG, int _EndB, bool _loop, int MaxPart = 0);
	CEmitter();
	~CEmitter();
	bool operator==(CEmitter& pEmitter);
	void Clear();
	bool IsFinished();
	bool Spawn();
	bool Despawn(CParticle& pParticle);
	void Update(float dT, CParticleManager *_Man);
	void RenderAll();
	void Start(){m_bSpawn = true;}
	void Stop(){m_bSpawn = false;}
	bool LoadXML(string filepath);
	//Accessors
	bool	GetInvert()		{return m_bInvert;		}
	int		GetImage()		{return m_nImage;		}
	float	GetStScale()	{return m_fStScale;		}
	float	GetStVelX()		{return m_fSVelX;		}
	float	GetStVelY()		{return m_fSVelY;		}
	float	GetStRot()		{return m_fStRot;		}
	float	GetEndScale()	{return m_fEndScale;	}
	float	GetEndVelX()	{return m_fEndVelX;		}
	float	GetEndVelY()	{return m_fEndVelY;		}
	float	GetEndRot()		{return m_fEndRot;		}
	float	GetLifeMin()	{return m_fLifeMin;		}
	float	GetLifeMax()	{return m_fLifeMax;		}
	float	GetPosX()		{return m_fPosX;		}
	float	GetPosY()		{return m_fPosY;		}
	int		GetPartWidth()	{return m_nPartWidth;	}
	int		GetPartHeight()	{return m_nPartHeight;	}
	int		GetStColorA()	{return m_nStAlpha;		}
	int		GetStColorR()	{return m_nStRed;		}
	int		GetStColorG()	{return m_nStGreen;		}
	int		GetStColorB()	{return m_nStBlue;		}
	int		GetEndColorA()	{return m_nEndAlpha;	}
	int		GetEndColorR()	{return m_nEndRed;		}
	int		GetEndColorG()	{return m_nEndGreen;	}
	int		GetEndColorB()	{return m_nEndBlue;		}
	float	GetCenterX()	{return m_fPosX + (0.5f * (m_fPosX2 - m_fPosX));}
	float	GetCenterY()	{return m_fPosY + (0.5f * (m_fPosY2 - m_fPosY));}
	//Mutators
	void SetInvert	(bool _Inverted)	{m_bInvert = _Inverted;	}
	void SetDelay	(float _delay)		{m_fSpawnDelay = _delay;}
	void SetMaxPart	(unsigned int max)	{m_unMaxPart = max;		}
	void SetPos		(float _PosX, float _PosY);
	void SetPos2	(float _PosX, float _PosY);
	void SetSVel	(float _VelX, float _VelY);
	void SetEVel	(float _VelX, float _VelY);
	void SetColor	(int _StA, int _StR, int _StG, int _StB, int _EndA, int _EndR, int _EndG, int _EndB);
};
#endif